.. __Basic Courses for Cars:
Basic Courses for Cars
========================
1. Motor Control
--------------
Effects: It can control the car to move forward, backward, turn left, turn right, rotate left and right, stop, etc., and the speed of the car can be set.
Effect demonstration:
.. figure:: ./img/电机控制G.gif
:align: center
:width: 80%
makecode program link: `https://makecode.microbit.org/S95796-94350-74983-15795 `_
Screenshot of makecode graphical interface:
.. figure:: ./img/电机控制C.png
:align: center
:width: 80%
2. Music Car
--------------
Effect: The car can play pre-set music.
makecode program link: `https://makecode.microbit.org/S93528-06251-15177-28056 `_
Screenshot of makecode graphical interface:
.. figure:: ./img/音乐小车C.png
:align: center
:width: 80%
1. Seven-Color Searchlight
--------------
Effect: The car is equipped with two colorful spotlights on the left and right sides, and the color and flashing pattern of the lights can be controlled by programming.
Effect demonstration:
.. figure:: ./img/七彩探照灯G.gif
:align: center
:width: 80%
makecode program link: `https://makecode.microbit.org/S48161-29282-53225-53062 `_
Screenshot of makecode graphical interface:
.. figure:: ./img/七彩探照灯C.png
:align: center
:width: 80%
4. RGB Running Light
--------------
Effect: Four WS2812 lights are installed at the bottom of the car. The color and flashing mode of the lights can be controlled by programming to realize the sequential color change of the marquee.
Effect demonstration:
.. figure:: ./img/RGB跑马灯G.gif
:align: center
:width: 80%
makecode program link: `https://makecode.microbit.org/S23470-56019-18472-86312 `_
Screenshot of makecode graphical interface:
.. figure:: ./img/RGB跑马灯C1.png
:align: center
:width: 100%
.. figure:: ./img/RGB跑马灯C2.png
:align: center
:width: 100%
.. figure:: ./img/RGB跑马灯C3.png
:align: center
:width: 100%
5. RGB Breathing Light
--------------
Effect: Four WS2812 lights are installed at the bottom of the car. The color and flashing mode of the lights can be controlled by programming to achieve a breathing light effect.
Effect demonstration:
.. figure:: ./img/RGB呼吸灯G.gif
:align: center
:width: 80%
makecode program link: `https://makecode.microbit.org/S42098-98692-58148-98413 `_
Screenshot of makecode graphical interface:
.. figure:: ./img/RGB呼吸灯C.png
:align: center
:width: 80%
6. Light Tracking
--------------
Effect: MicroBit comes with an ambient light sensor, which can be programmed to control the car to adjust its speed according to the intensity of light, thus achieving a light-chasing effect.
Effect demonstration:
.. figure:: ./img/追光G.gif
:align: center
:width: 80%
makecode program link: `https://makecode.microbit.org/S14523-36545-26778-18250 `_
Screenshot of makecode graphical interface:
.. figure:: ./img/追光C.png
:align: center
:width: 80%
7. Line Tracking
--------------
Effect: Two infrared sensors are installed on the bottom of the car. The car can be programmed to adjust its direction of travel according to the black lines on the ground, thus achieving the effect of tracking.
Effect demonstration:
.. figure:: ./img/巡线G.gif
:align: center
:width: 80%
makecode program link: `https://makecode.microbit.org/S82467-65410-61513-88116 `_
Screenshot of makecode graphical interface:
.. figure:: ./img/巡线C.png
:align: center
:width: 80%
8. Ultrasonic Ranging
--------------
Effect: An optional ultrasonic sensor is installed at the front of the car, which can be programmed to measure the distance to obstacles in front and display the result on MicroBit's LED screen.
.. tip:: Before using the ultrasonic function, you should switch to ultrasonic mode.
.. image:: /Tutorial/img/安装超声波.jpg
Effect demonstration:
.. figure:: ./img/超声波测距G.gif
:align: center
:width: 80%
makecode program link: `https://makecode.microbit.org/S98856-20868-77452-43719 `_
Screenshot of makecode graphical interface:
.. figure:: ./img/超声波测距C.png
:align: center
:width: 80%
9. Ultrasonic Obstacle Avoidance
--------------
Effect: An ultrasonic sensor can be optionally installed at the front of the car. The car can be programmed to measure the distance to obstacles in front and adjust its direction of travel according to the distance to achieve obstacle avoidance.
Effect demonstration:
.. figure:: ./img/超声波避障G.gif
:align: center
:width: 80%
makecode program link: `https://makecode.microbit.org/S20248-94240-76314-39688 `_
Screenshot of makecode graphical interface:
.. figure:: ./img/超声波避障C.png
:align: center
:width: 80%
10. Ultrasonic Following
--------------
Effect: An ultrasonic sensor can be optionally installed at the front of the car. It can be programmed to measure the distance to obstacles in front of it and adjust the driving speed according to the distance to achieve a following effect.
Effect demonstration:
.. figure:: ./img/超声波跟随G.gif
:align: center
:width: 80%
makecode program link: `https://makecode.microbit.org/S30884-31518-90039-02970 `_
Screenshot of makecode graphical interface:
.. figure:: ./img/超声波跟随C.png
:align: center
:width: 80%
11. Servo Drive
--------------
Effect: The car has a servo interface. By connecting a servo, the rotation angle of the servo can be controlled through programming to achieve some special actions.
Effect demonstration:
.. figure:: ./img/舵机驱动G.gif
:align: center
:width: 80%
makecode program link: `https://makecode.microbit.org/S43067-53664-12051-64290 `_
Screenshot of makecode graphical interface:
.. figure:: ./img/舵机驱动C.png
:align: center
:width: 80%
.. tip:: Due to limitations in installation space, weight, and power supply for the basic/ultrasonic/forklift form factors, adjustments may be necessary. Alternatively, you can combine them with other sensors and modules to achieve richer demonstration effects. Now, unleash your creativity and create your own cool effects.